from rest_framework import serializers
from rest_framework.validators import UniqueValidator

from apps.project.models import Project
from apps.users.models import UserProfile
from apps.users.serializers import UserDetailSerializer


class ProjectSerializers(serializers.ModelSerializer):
    creator = serializers.HiddenField(default=serializers.CurrentUserDefault())

    class Meta:
        model = Project
        fields = "__all__"


class ProjectListSerializers(serializers.ModelSerializer):
    username = serializers.CharField(source='creator.username')

    class Meta:
        model = Project
        fields = ['id', 'name', 'username', 'type', 'remark', 'add_time', 'edit_time']
